//
//  SINAHomeDateItemCollectionViewCell.m
//  sinashebao
//
//  Created by  androidlongs on 2018/1/12.
//  Copyright © 2018年  androidlongs. All rights reserved.
//

#import "SINAHomeDateItemCollectionViewCell.h"
#import "SINACircularBeadUtils.h"


@interface SINAHomeDateItemCollectionViewCell()

@property(assign,nonatomic) NSInteger yflagHeight;
@property(assign,nonatomic) NSInteger ysendflagHeight;


@end


@implementation SINAHomeDateItemCollectionViewCell

-(void)setBackGrouncWidth:(NSInteger)backGrouncWidth{
    _backGrouncWidth = backGrouncWidth;
    
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 8, backGrouncWidth, backGrouncWidth)];
    view.backgroundColor = [UIColor blueColor];
    [self addSubview:view];
    [SINACircularBeadUtils makeCircularView:view];
}
-(void)setModel:(SINADateModel *)model{
    _model = model;
    
    if (IS_IPHONE_X) {
        self.yflagHeight = 12;
        self.ysendflagHeight=self.yflagHeight+2;
    } else {
        self.yflagHeight = 6;
        self.ysendflagHeight=self.yflagHeight+2;
    }
    
    NSString *time = [NSString stringWithFormat:@"%@",model.day];
    
    [self removeAllSubviews];
    [self setBackgroundColor:[UIColor clearColor]];
    
    UILabel *timeLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.yflagHeight+14, self.backGrouncWidth, 21)];
    timeLabel.text = @"THUR";
    timeLabel.textAlignment = NSTextAlignmentCenter;
    timeLabel.font = [UIFont systemFontOfSize:14];
    timeLabel.textColor=[UIColor colorWithHexString:@"#349ef7"];
    
    [self addSubview:timeLabel];
    
    UILabel *dayLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, self.ysendflagHeight+34, self.backGrouncWidth, 21)];
    dayLabel.text = time;
    dayLabel.textColor=[UIColor colorWithHexString:@"#349ef7"];
    dayLabel.textAlignment = NSTextAlignmentCenter;
    dayLabel.font = [UIFont systemFontOfSize:20];
    
    [self addSubview:dayLabel];
    
    
    NSString *flagString = @"MON";
    switch ([model.week intValue]) {
        case 0:
            flagString =@"SUN";
            break;
        case 1:
            flagString =@"MON";
            break;
        case 2:
            flagString =@"TUES";
            break;
        case 3:
            flagString =@"WED";
            break;
        case 4:
            flagString =@"THUR";
            break;
        case 5:
            flagString =@"FRI";
            break;
        case 6:
            flagString =@"SAT";
            break;
            
        default:
            break;
    }
    
    timeLabel.text=flagString;
    WeakSelf;
    [[SINAUiviewClickLiserner alloc]viewClickFunction:self.contentView andWithBlick:^(UIView *view) {
        if (weakSelf.dateItemCollectViewBlock) {
            weakSelf.dateItemCollectViewBlock(weakSelf.model, weakSelf.pos);
        }
    }];
    

    
    
    
}
-(void)setTime:(NSString *)time{
    
    
}

@end
